{layout name="public/layout" /}
{include file='yxnavbar'}


<div class="main">
    {include file='../../plugin/lottery/template/web/lottery_common_nav'}
    {if $method == "lottery_main"}
    <div class="panel panel-info"   >
        <div class="panel-heading">当前数量： {$page_total}</div>
        <div class="panel-body">
            <form id = "myform" action="./index.php" method="get" class="form-horizontal" role="form">
                <input type="hidden" name="c" value="site" />
                <input type="hidden" name="a" value="entry" />
                <input type="hidden" name="m" value="{$_P['m']}" />
                <input type="hidden" name="do" value="web" />
                <input type="hidden" name="r" value="lottery" />
                <div class="form-group" style="float: right;">
                    {if count($themelist)>1 }
                    <div class="col-xs-12 col-sm-2 col-md-12">
                        <select onchange="submitForm();" class="form-control" name="themeid">
                            {loop $themelist $row}
                            <option value="{$row['id']}" {if $themeid == $row['id'] }selected="selected"{/if}>{$row['id']} - {php echo mb_substr($row['title'],0,8,'utf-8');}</option>
                            {/loop}
                        </select>
                    </div>
                    {else}
                    <input type="hidden" name="themeid" value="{$themeid}" />
                    {/if}
                </div>

                <div class="form-group" >
                    <label class="col-xs-1 col-sm-2 col-md-1 control-label text-center">操作</label>
                  <!--<div class="form-group" {if $show_list_total>=8 && $total!=0} style="display:none;"{/if}>-->
                    <div class="col-sm-1 col-lg-1 col-md-1 col-xs-2">
                        <a onclick="addItem()" class="btn btn-primary">添加奖项</a>
                    </div>
                    {if $is_mult_lt && $total>8}
                        <div class="col-sm-2 col-lg-2 col-md-2 col-xs-2">
                            <a onclick="changeDefaultPrizeGroup(this)" data-themeid="{$themeid}" class="btn btn-primary">切换奖品组</a>
                        </div>
                    {/if}
                    {if $total==0  && $default_type==0}

                    <div class="col-sm-2 col-lg-2 col-md-2 col-xs-2">
                        <a onclick="addDefaultItems(this)" data-themeid="{$themeid}" class="btn btn-primary">一键添加示例奖项</a>
                    </div>
                    <div class="col-sm-2 col-lg-2 col-md-2 col-xs-2" style="margin-left: 10px;">
                        <a href="{php echo createWebUrlPlugin('lottery.downLoad',array('themeid'=>$themeid));}"  target="_blank" class="btn btn-primary">下载奖品模版Excel</a>
                    </div>
                    {/if}

                    <div class="col-sm-2 col-lg-1 col-md-2 col-xs-2" style="margin-left: .1rem;float:right;">
                        <input class="btn btn-default" type="button" name="virtual" id="virtual" value="增加虚拟数据">
                    </div>
                </div>

            </form>

            {if $total==0  && $default_type==0}
            <form id = "uploadForm"  class="form-horizontal" role="form">

                <div class="form-group">
                    <div class="col-sm-2 col-xs-12">
                        <div class="input-group">
                            <input type="file" class="form-control" name="file"  value="">
                        </div>
                    </div>
                    <div class="col-sm-1 col-lg-1 col-md-1 col-xs-2">
                        <a class="btn btn-default" onclick="uploadFile()"><i class="fa fa-search"></i> 上传文件</a>
                    </div>
                </div>
            </form>
            {/if}
        </div>
    </div>
    {/if}
    <input type="hidden" name="current_ac" id="current_ac" value="{$ac}">
    <input type="hidden" name="prize_total" id="prize_total" value="{$show_list_total}">
    <input type="hidden" name="free_num" id="free_num" value="{$free_count}">
    <input type="hidden" name="is_double" id="is_double" value="{$is_double}">
    <input type="hidden" name="double_num" id="double_num" value="{$double_num}">
    <input type="hidden" name="bizhoing_num" id="bizhoing_num" value="{$bizhoing_count}">
    <input type="hidden" name="is_full_pr" id="is_full_pr" value="{$is_full_pr}">
    <input type="hidden" name="total_day_qty" id="total_day_qty" value="{$total_day_qty}">
    <input type="hidden" name="open_send_redpackage" id="open_send_redpackage" value="{$open_send_redpackage}">


    <div class="tab-content">
        <div class="panel panel-default">
            <div class="panel-body table-responsive">
                <table class="table table-hover">
                    <thead class="navbar-inner">
                    <tr>
                        <th style="width: 50px">序号</th>
                        <th style="width: 50px">奖品图</th>
<!--                        <th style="width: 100px">奖项名称</th>-->
                        <th style="width: 120px">奖品名称</th>

                        <th style="width: 180px">总库存</th>
                        <th style="width: 80px">可用库存</th>
                        <th style="width: 100px">已抽出</th>
                        <th style="width: 100px">每日发放上限</th>
                        <th style="width: 120px">中奖概率</th>
                        <th style="width: 120px">前端展示占比</th>
                        {if $_C['yx_lt_open_red_package']==1}
                        <th style="width: 160px">红包每日发放数量</th>
                        <th style="width: 160px">单个红包金额</th>
                        {/if}
                        {if $system['fenxiao']  && $_C['yx_lt_open_red_package']==1}
                        <th style="width: 80px">奖品类型</th>
                        {/if}
                        <th style="width: 100px">奖品属性</th>
                        <th style="width: 100px">奖品唯一性</th>
                        <th style="width: 80px">奖项状态</th>
                        <th style="width: 180px">排序</th>
                        <th style="width: 140px;text-align: right">操作</th>
                    </tr>
                    </thead>
                    <tbody>
                        {loop $list $key $item}
                            <tr>
                                <td>{php echo $key+1;}</td>
                                <td><a href="{php echo tomedia($item['small_img']);}"  target="_blank" title="查看原图"><img src="{php echo tomedia($item['small_img']);}" style="width: 40px;height: 40px;padding: 1px;"></a></td>

<!--                                <td>{$item['name']}</td>-->
                                <td>{$item['title']}</td>

                                {if $item['default_type']==2}
                                <td>
                                    无限制
                                </td>
                                {else}
                                    <td style="white-space: nowrap;">
                                        <a class="btn btn-warning btn-sm" style="white-space: nowrap;" onclick="editItemQty(this)" data-action="add" data-themeid="{$themeid}" data-id="{$item['p_id']}" title="添加库存" data-toggle="tooltip" data-placement="top" >
                                            <i class="fa fa-plus" style="white-space: nowrap;" aria-hidden="true"></i></i>
                                        </a>
                                        {$item['total_qty']}
                                        <a class="btn btn-danger btn-sm" style="white-space: nowrap;" onclick="editItemQty(this)" data-action="minus" data-themeid="{$themeid}" data-id="{$item['p_id']}" title="减少库存" data-toggle="tooltip" data-placement="top" >
                                            <i class="fa fa-minus" style="white-space: nowrap;" aria-hidden="true"></i></i>
                                        </a>
                                    </td>
                                {/if}
                                <td>{if $item['default_type']==2}无限制{else}{$item['qty']}{/if}</td>
                                <td>{$item['out_qty']}</td>

                                <td>
                                    {if $item['default_type']==2}
                                      无上限
                                    {else}
                                      <input type="number" name="day_qty" style="width: 55px;" data-themeid="{$themeid}" data-id="{$item['p_id']}" value="{php echo $item['day_qty'];}">
                                    {/if}
                                </td>
                                <td>
                                    <input type="number" name="pr" style="width: 75px;" data-themeid="{$themeid}" data-id="{$item['p_id']}" value="{php echo $item['pr'];}">
                                    <br>
                                    <span class="lt_tr_tips" style="font-size: 12px;{if $item['default_type']==3}color: #5CB85D;{else}color: gray;{/if}">真实概率:{php echo $item['format_pr'];}%</span>
                                </td>
                                <td>
                                    <input type="number" name="show_pr" style="width: 75px;" data-themeid="{$themeid}" data-id="{$item['p_id']}" value="{php echo $item['show_pr'];}">
                                    <br>
                                    <span class="lt_tr_tips" style="font-size: 12px;color: gray;">真实占比:{php echo $item['format_show_pr'];}%</span>
                                </td>
                                {if $system['fenxiao'] && $_C['yx_lt_open_red_package']==1}
                                <td>{if $item['type']!='default'}{$item['red_envelopes_day_qty']}{/if}</td>
                                <td>{if $item['type']!='default'}{if $item['red_envelopes_amount_min']==$item['red_envelopes_amount_max']}{$item['red_envelopes_amount_min']}{else}{$item['red_envelopes_amount_min']} ~ {$item['red_envelopes_amount_max']}{/if}{/if}</td>
                                {/if}
                                {if $system['fenxiao'] && $_C['yx_lt_open_red_package']==1}
                                <td>{if $item['type']=='default' || !$item['type']}
                                    <span class="label label-success">实物奖品</span>
                                    {else}
                                    <span class="label label-danger ">红包奖品</span>
                                    {/if}
                                </td>
                                {/if}
                                  <td>
                                    {if $item['default_type']==1}
                                    <span class="label label-info ">正常奖项</span>
                                    {elseif $item['default_type']==2}
                                    <span class="label label-danger">谢谢参与</span>
                                    {else}
                                    <span class="label label-success">必中奖项</span>
                                    {/if}
                                </td>
                                <td>
                                    {if $item['default_type']==2}
                                    {else}
                                        {if $is_double}
                                        <span class="label label-info ">重复性奖项</span>
                                        {else}
                                        <span class="label label-success">唯一性奖项</span>
                                        {/if}
                                    {/if}
                                </td>
                                <td>
                                    {if $item['status']==1}
                                    <span class="label label-primary ">上架</span>
                                    {elseif $item['status']==2}
                                    <span class="label label-danger">下架</span>
                                    {else}
                                    <span class="label label-success">库存不足</span>
                                    {/if}
                                </td>
                                <td>
                                    {if $key!=0}
                                    <a class="btn btn-success btn-xs" onclick="editItemSort(this)" data-action="up" data-sort="{$item['show_sort']}" data-themeid="{$themeid}" data-id="{$item['p_id']}" title="向上移动" data-toggle="tooltip" data-placement="top" ><i class="fa fa-chevron-up" aria-hidden="true"></i></i></a>
                                    {else}
                                    <!--                                    <a class="btn btn-success btn-sm"  data-action="up" data-sort="{$item['show_sort']}" data-themeid="{$themeid}" data-id="{$item['p_id']}" title="向上移动" data-toggle="tooltip" data-placement="top" ><i class="fa fa-chevron-up" aria-hidden="true"></i></i></a>-->
                                    {/if}

                                    {if ($key+1)!=count($list)}
                                    <a class="btn btn-success btn-xs" onclick="editItemSort(this)" data-action="down" data-sort="{$item['show_sort']}" data-themeid="{$themeid}" data-id="{$item['p_id']}" title="向下移动" data-toggle="tooltip" data-placement="top"><i class="fa fa-chevron-down" aria-hidden="true"></i></a>
                                    {else}
                                    <!--                                    <a class="btn btn-success btn-sm" onclick="editItemSort(this)" data-action="down" data-sort="{$item['show_sort']}" data-themeid="{$themeid}" data-id="{$item['p_id']}" title="向下移动" data-toggle="tooltip" data-placement="top"><i class="fa fa-chevron-down" aria-hidden="true"></i></a>-->
                                    {/if}
                                </td>
                                <td style="text-align: right">



                                    <a class="btn btn-primary btn-sm" style="width: 35px" onclick="changeOrDelItem(this)" data-type="edit" data-itemtype="{$item['type']}"
                                       data-edit-url="{php echo createWebUrlPlugin('lottery.edit',array('themeid'=>$themeid,'p_id'=>$item['p_id']));}"
                                       data-themeid="{$themeid}" data-id="{$item['p_id']}"  title="修改奖品信息" data-toggle="tooltip" data-placement="top"><i class="fa fa-pencil-square-o"> </i></a>
<!--                                    <a class="btn btn-danger btn-sm" style="width: 35px" onclick="changeOrDelItem(this)" data-type="del"-->
<!--                                       data-edit-url="{php echo createWebUrlPlugin('lottery.delete');}" data-themeid="{$themeid}" data-id="{$item['p_id']}" title="删除奖品" data-toggle="tooltip" data-placement="top"><i class="fa fa-times"> </i></a>-->
                                </td>
                            </tr>
                        {/loop}
                    </tbody>
                </table>
            </div>
        </div>
    </div>

</div>

{$pager}


<!--增加虚拟数据弹屏-->
<div class="virtual" style="width: 40vw;height: 40vh;z-index:10;display:none;position: fixed;top: 50%;left: 50%;transform: translate(-50%,-50%) ">
    <div class="panel panel-info">
        <div class="panel-heading" style="background-color: #428bca;color: #f7f7f7;">
            <span>增加虚拟中奖记录</span>
            <span class="close_virtual" style="float: right;">关闭</span>
        </div>
        <div class="panel-body">
            <form id ="myform1"  class="form-horizontal" role="form" style="margin: 0 auto;">
                <div class="form-group" style="margin-left: 0px;">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">虚拟奖项</label>
                    <div class="col-sm-10  col-xs-12">
                        {loop $prize_arr $index $row}
                        {if $index>0}
                        <label class="radio-inline">
                            <input name="virtual_pids[]" type="checkbox" value="{$row['p_id']}" {if $index>0} checked{/if}> {$row['title']}
                        </label>
                        {/if}
                        {/loop}
                    </div>
                </div>
                <div class="form-group" style="margin-left: 0px;">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">虚拟中奖时间</label>
                    <div class="col-sm-3 col-lg-3 col-md-3 col-xs-6">
                        {php echo view_form_field_daterange('virtualtime', array('start'=>date('Y-m-d H:i:s',time()),'end'=>date('Y-m-d H:i:s',$end_time)), true);}
                    </div>
                </div>
                <div class="form-group" style="margin-left: 0px;">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">虚拟中奖数量</label>
                    <div class="col-sm-3 col-lg-3 col-md-3 col-xs-6">
                        <input class="form-control" name="virtual_num" id="virtual_num" placeholder="输入虚拟中奖数量" type="number" value="">
                    </div>
                </div>

                <div class="form-group" id="sub_upload06" >
                    <div class=" col-sm-12">
                        <input  onclick="addVirtualData()"  type="button" value="提交" class="btn btn-primary col-lg-2">
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
<script type="text/javascript">
    $(document).ready(
        function (){
            //检车后台设置未中奖奖品
            let  default_type = "{php echo $_P['default_type'];}"
            let prize_total = $("#prize_total").val();
            let is_double = $("#is_double").val();
            let total_day_qty = $("#total_day_qty").val();
            let double_num = $("#double_num").val();
            let bizhoing_num = $("#bizhoing_num").val();
            let free_num = $("#free_num").val();
            let has_big_prize_count = "{php echo $has_big_prize_count;}"
            let yx_lt_chance_limit = "{php echo $yx_lt_chance_limit;}"
            if (prize_total<8){
                layer.msg('后台设置奖项错误，必须设置8个上架状态奖项');
                return
            }
            let is_full_pr = $("#is_full_pr").val();
            // if (is_full_pr!=100){
            //     var msg = '中奖概率总和需要等于100,'+'当前总和为'+is_full_pr;
            //     layer.msg(msg);
            //     return
            // }
            if (is_double==0 && !has_big_prize_count){
                let msg = '当前配置需设置大库存奖品个数为'+yx_lt_chance_limit+'个；大库存奖品是指奖品库存数大于1000;';
                layer.confirm(msg,{title:'配置提醒',icon:'2'});
            }
            if (is_double==0 && double_num>0){
                let msg = '存在重复性奖项，请修改为唯一性奖项';
                layer.confirm(msg,{title:'配置提醒',icon:'2'});
            }
            // if (is_double==0 && total_day_qty<=0){
            //     let msg = '各个奖品每日发放上限总和不能为0';
            //     layer.confirm(msg,{title:'配置提醒',icon:'2'});
            // }
            if (is_double==1 && double_num<=0){
                let msg = '重复性奖项必须存在，并且大于等于一个';
                layer.confirm(msg,{title:'配置提醒',icon:'2'});
            }
            if (is_double==1){
                if (double_num<=0){
                    let msg = '重复性奖项必须存在，并且大于等于一个';
                    layer.confirm(msg,{title:'配置提醒',icon:'2'});
                }
                // if (free_num>=1){
                //     let msg = '重复性中奖，不可设置未中奖奖项';
                //     layer.confirm(msg,{title:'配置提醒',icon:'2'});
                // }
            }else{
                // if (bizhoing_num<1){
                //     let msg = '必须设置必中奖奖项';
                //     layer.confirm(msg,{title:'配置提醒',icon:'2'});
                // }
            }
        }

    );
    $("#virtual").click(function () {
        let total_show_pr = "{$total_show_pr}";
        if (total_show_pr<=0){
            let msg = '奖项列表中奖记录占比设置不合法，虚拟奖项的中奖记录占比需大于0';
            layer.confirm(msg,{title:'配置提醒',icon:'2'});
        }
        $('.virtual').show();
    })
    $('.close_virtual').click(function () {
        $('.virtual').hide();
    });
    function addVirtualData()
    {
        let postUrl = "{php echo createWebUrlPlugin('lottery.flag.virtual',array('themeid'=>$themeid));}";
        let jump_url = "{php echo createWebUrlPlugin('lottery.flag',array('themeid'=>$themeid,'status'=>'-1'));}";
        let formData = $("#myform1").serialize();
        $.ajax({
            url:postUrl,
            dataType:'json',
            method:'post',
            data:formData,
            success:function (e) {
                let status = e.status;
                let result = e.result;
                if (status!=1){
                    layer.msg(result.msg)
                }else{
                    layer.msg(result.msg);
                    setTimeout(function () {
                        window.location.href = jump_url;
                    },500);
                }
            },
            fail:function (err) {
                console.log(err)
            }
        })
    }


    $("input[name='pr']").on('blur',function () {
        var p_id = $(this).data('id');
        var themeid = $(this).data('themeid');
        var value = $(this).val();
        editItem('pr',value,themeid,p_id)
    });

    $("input[name='show_pr']").on('blur',function () {
        var p_id = $(this).data('id');
        var themeid = $(this).data('themeid');
        var value = $(this).val();
        editItem('show_pr',value,themeid,p_id)
    });
    // $("input[name='out_qty']").on('bulr',function () {
    //     var p_id = $(this).data('id');
    //     var themeid = $(this).data('themeid');
    //     var value = $(this).val();
    //     editItem('out_qty',value,themeid,p_id)
    // });
    $("input[name='day_qty']").on('blur',function () {
        var p_id = $(this).data('id');
        var themeid = $(this).data('themeid');
        var value = $(this).val();
        editItem('day_qty',value,themeid,p_id)
    });
    function addItem()
    {
        let prize_total = $("#prize_total").val();
        let jump_url = "{php echo createWebUrlPlugin('lottery.add',array('themeid'=>$themeid));}";
        if (prize_total>=8){
            layer.msg('上架奖品达到8个，无法添加');
        }else{
            window.open(jump_url);
        }
    }
    function submitForm(){
        var form = document.getElementById("myform");
        form.submit();
    }

    function uploadFile(){
        var formData = new FormData($( "#uploadForm" )[0]);
        postUrl = "{php echo createWebUrlPlugin('lottery.uploadFile',array('themeid'=>$themeid));}";
        layer.msg('您确定导入电子表格中的全部记录吗？',{
            btn:['确定','取消'],
            yes:function (index) {
                $.ajax({
                    url:postUrl,
                    dataType:'json',
                    method:'post',
                    data: formData,
                    processData: false,
                    contentType: false,
                    success:function (e) {
                        let res = e.message;
                        let code = res.code;
                        let msg = res.msg;
                        if (code!=200){
                            layer.msg(msg);
                        }else{
                            layer.msg(msg);
                            location.reload();
                        }
                    },
                    fail:function (err) {
                        console.log(err)
                    }
                });
            }
        });

    }

    function editItem(type,value,themeid,p_id)
    {
        var postUrl = "{php echo createWebUrlPlugin('lottery.editItem');}";
        $.ajax({
            url:postUrl,
            dataType:'json',
            method:'post',
            data: {p_id:p_id,themeid:themeid,type:type,val:value},
            success:function (e) {

                let res = e.result;
                let status = res.status;
                let msg = res.msg;
                if (status!=1){
                    $('.lt_tr_tips').hide();
                    layer.msg(msg);
                }else{
                    layer.msg(msg);
                }
            },
            fail:function (err) {
                console.log(err)
            }
        });
    }
    function editItemSort(e){
        let p_id = e.getAttribute("data-id");
        let action = e.getAttribute("data-action");
        let themeid = e.getAttribute("data-themeid");
        let sort = e.getAttribute("data-sort");
        var postUrl = "{php echo createWebUrlPlugin('lottery.editSortItem');}";
        $.ajax({
            url:postUrl,
            dataType:'json',
            method:'post',
            data: {p_id:p_id,themeid:themeid,action:action,sort:sort},
            success:function (e) {
                let res = e.result;
                let status = res.status;
                let msg = res.msg;
                if (status!=1){
                    layer.msg(msg);
                }else{
                    layer.msg(msg);
                }
                location.reload();
            },
            fail:function (err) {
                console.log(err)
            }
        });
    }
    //修改奖品库存
    function editItemQty(e){
        let action = e.getAttribute("data-action");
        let p_id = e.getAttribute("data-id");
        let themeid = e.getAttribute("data-themeid");
        var postUrl = "{php echo createWebUrlPlugin('lottery.editItemQty');}";

        var title_str = '';
        if (action=='add'){
            title_str = '请输入增加库存数';
        }else{
            title_str = '请输入减少库存数';
        }
        layer.prompt({
            formType: 3,
            value: 1,
            title: title_str,
            area: ['300px', '50px'] //自定义文本域宽高
        }, function(value, index, elem){
            $.ajax({
                url:postUrl,
                dataType:'json',
                method:'post',
                data: {p_id:p_id,themeid:themeid,action:action,qty:value},
                success:function (e) {
                    let res = e.result;
                    let status = res.status;
                    let msg = res.msg;
                    if (status!=1){
                        layer.msg(msg);
                    }else{
                        layer.msg(msg);
                    }
                    location.reload();
                },
                fail:function (err) {
                    console.log(err)
                }
            });
        });


    }
    // 修改、删除奖品
    function changeOrDelItem(e) {
        let p_id = e.getAttribute("data-id");
        let type = e.getAttribute("data-type");
        let themeid = e.getAttribute("data-themeid");
        let redirectUrl = e.getAttribute("data-edit-url");
        let item_type = e.getAttribute("data-itemtype");
        let open_send_redpackage = $("#open_send_redpackage").val();
        let postUrl ="";
        if (type=='edit'){
            if (!open_send_redpackage && item_type!='default'){
                layer.msg('抽奖红包设置未开启，禁止编辑！');
                return;
            }
            window.location.href = redirectUrl;
            // window.open(redirectUrl);
        }
        if (type=='del'){
            return;
            postUrl = redirectUrl;
            layer.msg('您确定删除该奖品吗？',{
                btn:['确定','取消'],
                yes:function (index) {
                    $.ajax({
                        url:postUrl,
                        dataType:'json',
                        method:'post',
                        data: {p_id:p_id,themeid:themeid},
                        success:function (e) {
                            let res = e.result;
                            let status = res.status;
                            let msg = res.msg;
                            if (status!=1){
                                layer.msg(msg);
                            }else{
                                layer.msg(msg);
                            }
                        },
                        fail:function (err) {
                            console.log(err)
                        }
                    });
                    location.reload();
                }
            });
        }
    }
    //添加测试数据
    function addDefaultItems(e)
    {
        var postUrl = "{php echo createWebUrlPlugin('lottery.defaultItems');}";
        let themeid = e.getAttribute("data-themeid");
        $.ajax({
            url:postUrl,
            dataType:'json',
            method:'post',
            data: {themeid:themeid},
            success:function (e) {
                let res = e.result;
                let status = res.status;
                let msg = res.msg;
                if (status!=1){
                    layer.msg(msg);
                }else{
                    layer.msg(msg);
                }
                location.reload();
            },
            fail:function (err) {
                console.log(err)
            }
        });

    }

    //切换奖品组
    function changeDefaultPrizeGroup(e)
    {
        var postUrl = "{php echo createWebUrlPlugin('lottery.changePrizeGroup');}";
        let themeid = e.getAttribute("data-themeid");
        $.ajax({
            url:postUrl,
            dataType:'json',
            method:'post',
            data: {themeid:themeid},
            success:function (e) {
                let res = e.result;
                let status = e.status;
                let msg = res.msg;
                if (status!=1){
                    layer.msg(msg);
                }else{
                    layer.msg(msg);
                    console.log(123)
                    setTimeout(function () {
                        console.log(321)
                        location.reload();
                    },500);
                }
            },
            fail:function (err) {
                console.log(err)
            }
        });

    }
</script>
